/**
 * Created by mapbar_front on 2019/8/10.
 */
import React,{Component} from 'react';

class RefsDOM extends Component{
    constructor(props){
        super(props);
        this.ref = React.createRef();
    }
    componentDidMount(){
        console.log('this.ref',this.ref.current);
    }
    handleClick=()=>{
        this.ref.current.focus();
    }
    componentWillUnmount(){
        console.log('componentWillUnmount',this.ref);
    }
    render(){
        return(
            <div>
                <input type="text" ref={this.ref}/>
                <button onClick={this.handleClick}>
                    点击
                </button>
            </div>
        )
    }
}
export default RefsDOM;
